close all;
[val text raw] = xlsread('VNIBOR.xlsx',10);
ncol = size(val,2);

Standardize = false;
col = [4 5 7 ];
% Y = val(:,2);
Y = val(2,2:end);
X = val(:,col);

N = size(val,1);
Ntrain = floor(N.*3./4);
Ntest = size(val,1) - Ntrain;

Xtrain = X(1:Ntrain,:);
Ytrain = Y(1:Ntrain);

%% multiple class
SVMModels = cell(3,1);
classes = unique(Y);
rng(1); % For reproducibility

for j = 1:numel(classes);
    indx = strcmp(Y,classes(j)); % Create binary classes for each classifier
    SVMModels{j} = fitcsvm(X,indx,'ClassNames',[false true],'Standardize',true,...
        'KernelFunction','rbf','BoxConstraint',1);
end


%%

[heart_scale_label, heart_scale_inst] = libsvmread('heart_scale');
% model = svmtrain2(heart_scale_label, heart_scale_inst, '-c 1 -g 0.07 -b 1');


train_data = heart_scale_inst(1:150,:);
train_label = heart_scale_label(1:150,:);
test_data = heart_scale_inst(151:270,:);
test_label = heart_scale_label(151:270,:);

% model = svmtrain2(heart_scale_label, heart_scale_inst, '-c 1 -g 0.07 -b 1');
model_linear = svmtrain2(train_label, train_data, '-b 1');
[predict_label_L, accuracy_L, dec_values_L] = svmpredict(test_label, test_data, model_linear);
accuracy_L

% model_precomputed = svmtrain(train_label, [(1:150)', train_data*train_data'], '-t 4');
% [predict_label_P, accuracy_P, dec_values_P] = svmpredict(test_label, [(1:120)', test_data*train_data'], model_precomputed);


